PTHMINT-118: POS receipt and order cancel features#57
Open
PTHMINT-118: POS receipt and order cancel features#57
Conversation
Introduce POS and order cancellation functionality: add PosManager with get_receipt and add cancel_transaction to OrderManager. Support terminal-group scoped authentication for order create and cancel (AuthScope / ScopedCredentialResolver) and ensure order_id path segments are encoded. Add request/response models for cancel transaction and rich receipt models with component types (merchant, order, items, tips, payment, related transactions). Wire PosManager into Sdk. Include examples for Cloud POS create, cancel, and fetching receipts. Add unit and integration tests covering create with terminal-group scope, cancel_transaction behavior, PosManager.get_receipt, and existing order operations.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #57 +/- ##
==========================================
+ Coverage 91.82% 92.83% +1.00%
==========================================
Files 148 164 +16
Lines 2655 2889 +234
==========================================
+ Hits 2438 2682 +244
+ Misses 217 207 -10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
danielcivit
requested changes
May 5, 2026
Member
danielcivit
left a comment
There was a problem hiding this comment.
- I reported a few inline bugs in the code (typos and non existing arguments within a API response).
- Also a comment - question about code consistency and conventions previously adopted related to the custom_api_response, custom_cancel_transaction_response, within OrderManager class.
| """Order information included in receipt data.""" | ||
|
|
||
| amount: Optional[int] | ||
| amount_refunded: Optional[int] |
Member
There was a problem hiding this comment.
This should be "amountrefunded" following API docs. Or is docs wrong.
The following is an example of this API response:
{'data': {'merchant': {'address': 'Vijzelstraat Amsterdam', 'name': 'MultiSafepay B.V.'}, 'order': {'amount': 100, 'amountrefunded': 0, 'completed': '2026-05-05T12:18:27', 'currency': 'EUR', 'items': None, 'tip': None, 'transaction_id': '1777976306101201'}, 'payment': {'application_id': 'a0000000041010', 'authorization_code': '006459', 'card_acceptor_location': 'Amsterdam', 'card_entry_mode': 'ICC_CONTACTLESS', 'card_expiry_date': '3303', 'cardholder_verification_method': 'NO_CVM_REQUIRED', 'issuer_bin': '548913', 'issuer_country_code': None, 'last4': '6907', 'payment_method': 'MASTERCARD', 'response_code': '00', 'terminal_id': '000013Z1'}, 'printed_on': '2026-05-05T14:36:54', 'related_transactions': None}, 'success': True}
Collaborator
Author
There was a problem hiding this comment.
I implemented an open solution that preserves our conventions and aligns with the documentation
Align response models with POS schemas: remove customer and items from CancelTransaction and add order_id. Rename ReceiptOrder.amount_refunded to amountrefunded to match API payload. Inline the custom cancel transaction response construction into OrderManager.get (remove the private helper). Update unit tests to assert the new fields and exclusions.
Add a compatibility alias for refunded amounts on ReceiptOrder: a read-only property amount_refunded that returns amountrefunded, and update from_dict to accept amount_refunded input by mapping it to amountrefunded. Update unit tests to import ReceiptOrder, assert the new alias in existing receipt parsing test, and add a new test to verify parsing of amount_refunded. Also simplify the Cloud POS example output to print the full order object instead of conditional payment URL printing. These changes ensure the API model accepts both naming conventions and that behavior is covered by tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces support for cancelling Cloud POS orders and improves the example scripts and internal API structure for order cancellation and receipt fetching. The main changes include the addition of a new
cancel_transactionmethod to theOrderManager, new request and response models for order cancellation, and several new and updated example scripts demonstrating Cloud POS order creation, cancellation, and receipt retrieval.New Cloud POS order cancellation support:
OrderManager.cancel_transactionmethod: Adds a new method to cancel POS transactions by order ID, supporting both direct order ID strings and request objects, with optional terminal group scoping.CancelTransactionRequestandCancelTransactionmodels for request and response handling. [1] [2]__init__.pyfiles to expose these models and document their purpose. [1] [2] F37e056cR1)OrderManagerand its response handling. [1] [2]Example scripts for Cloud POS flows:
examples/order_manager/cancel.pyto demonstrate Cloud POS order creation, waiting, and cancellation.examples/order_manager/cloud_pos_order.pyto demonstrate Cloud POS order creation with terminal-group scoped authentication.examples/pos_manager/get_receipt.pyto show both receipt fetching for an existing order and a complete flow including order creation, event monitoring, and receipt retrieval.Improvements to authentication and scoping:
These changes collectively provide a full workflow for Cloud POS order management, including creation, cancellation, and receipt retrieval, with improved code organization and documentation.